package nuig.prolog.PrologAccess.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

import alice.tuprolog.MalformedGoalException;
import alice.tuprolog.SolveInfo;

import nuig.prolog.PrologAccess.BaseProcess;

public class MeaningProcess extends BaseProcess {

	/*
	 * initial
	 */
	public MeaningProcess() throws Exception {
		super();
	}

	/**
	 * 
	 */
	public boolean isSuccess(String PLcode) {
		this.answer = PLcode;
		return executeIsSuccess();
	}
	


	public List<String> GetAnswer(String PLcode) throws MalformedGoalException {
		this.answer = PLcode;
		info=engine.solve(answer);
		List<String> answer = new ArrayList<String>();
		try {
			while (info.isSuccess() && engine.hasOpenAlternatives()) {
				answer.add(info.getTerm("X").toString());
				info = engine.solveNext();// get next solution
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return answer;
	}

}
